package com.hmall.item.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitConfig {

    @Bean
    public TopicExchange topicExchange() {
        return new TopicExchange("hmall.topic");
    }

    @Bean
    public Queue insertQueue() {
        return new Queue("hmall.insert.queue");
    }

    @Bean
    public Queue deleteQueue() {
        return new Queue("hmall.delete.queue");
    }

    @Bean
    public Binding binding1() {
        return BindingBuilder.bind(insertQueue()).to(topicExchange()).with("hmall.insert");
    }

    @Bean
    public Binding binding2() {
        return BindingBuilder.bind(deleteQueue()).to(topicExchange()).with("hmall.delete");
    }
}
